<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>htonl</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4>NAME</h4><blockquote>
htonl, htons, ntohl, ntohs - convert values between host and network byte order
</blockquote><h4>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="arpainet.h.html">arpa/inet.h</a>&gt;

uint32_t htonl(uint32_t hostlong);

uint16_t htons(uint16_t hostshort);

uint32_t ntohl(uint32_t netlong);

uint16_t ntohs(uint16_t netshort);
</code>
</pre>
</blockquote><h4>DESCRIPTION</h4><blockquote>
These functions convert 16-bit and 32-bit quantities between network byte
order and host byte order.
<p>
The 
<B>uint32_t</B>
and 
<B>uint16_t</B>
types are made available by inclusion of
<i><a href="../xsh/inttypes.h.html">&lt;inttypes.h&gt;</a></i>
(see referenced document
<B>XSH</B>).
</blockquote><h4>RETURN VALUES</h4><blockquote>
The
<i>htonl()</i>
and
<i>htons()</i>
functions return the argument value converted from host to network byte order.
<p>
The
<i><a href="ntohl.html">ntohl()</a></i>
and
<i>ntohs()</i>
functions return the argument value converted from network to host byte order.
</blockquote><h4>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4>APPLICATION USAGE</h4><blockquote>
These functions are most often used in conjunction with Internet
addresses and ports as returned by
<i><a href="gethostent.html">gethostent()</a></i>
and
<i><a href="getservent.html">getservent()</a></i>.
<p>
On some architectures these functions are defined as macros that expand to the
value of their argument.
</blockquote><h4>SEE ALSO</h4><blockquote>
<i><a href="endhostent.html">endhostent()</a></i>,
<i><a href="endservent.html">endservent()</a></i>,
<i><a href="arpainet.h.html">&lt;arpa/inet.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
